package warmup.quicksort;

import java.util.Scanner;

public class VogellaSolution
{
	public static void sort(int[] arr, int initial, int last)
	{
		int left = initial, right = last;
		int pivot = arr[initial + (last - initial)/2];
		
		while (left <  right){
			
			while(arr[left] < pivot){
				left++;
				
			}
			while(arr[right] > pivot){
				right--;
				
			}
			if(left <= right){
				swap(arr,left,right);
				left++;
				right--;
			}
		}
		if(initial < right){
			sort(arr, initial, right);
		}
		
		if(left < last){
			sort(arr,left, last);
		}		
	}
	
	public static void swap(int[] arr, int i, int j){
		int temp = arr[i];
		arr[i] = arr[j];
		arr[j] =temp;
	}
	
	public static void printArray( int[] arr){
		
		for(int n:arr){
			System.out.print(n + " ");
		}
		System.out.println();
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int n = Integer.parseInt(line);
		
		line = sc.nextLine();
		String[] numbers = line.split(" ");
		int[] arr = new int[n];		
		
		for(int i = 0; i < n ; i++){
				arr[i] = Integer.parseInt(numbers[i]);				
		}
		
		
		sort(arr, 0, arr.length-1);
		printArray(arr);
	}
}